🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / app / src / main / java / com / geeksville / mesh / model / DeviceVersion.kt
Displaying Raw • Download
app/src/main/java/com/geeksville/mesh/model/DeviceVersion.kt ui_message_list (be3f882f) Text, 1.79 KB
T8b949e/*
* Copyright (c) 2025 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787com.geeksville.mesh.model
Tff7b72import T7ee787com.geeksville.mesh.android.Logging
T8b949e/**
* Provide structured access to parse and compare device version strings
*/
Tff7b72data Tff7b72class T56d364DeviceVersionTb4b4b4(Tff7b72val Te6edf3asStringTb4b4b4: Tffa657StringTb4b4b4) Tb4b4b4: Te6edf3ComparableTff7b72<Te6edf3DeviceVersionTff7b72>Tb4b4b4, Te6edf3Logging Tb4b4b4{
Tff7b72val Te6edf3asInt
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Tff7b72try Tb4b4b4{
Te6edf3verStringToIntTb4b4b4(Te6edf3asStringTb4b4b4)
Tb4b4b4} Tff7b72catch Tb4b4b4(Te6edf3eTb4b4b4: Te6edf3ExceptionTb4b4b4) Tb4b4b4{
Te6edf3warnTb4b4b4(Ta5d6ff"Ta5d6ffException while parsing version 'Tffd700$Te6edf3asStringTa5d6ff', assuming version 0Ta5d6ff"Tb4b4b4)
T79c0ff0
Tb4b4b4}
T8b949e/**
* Convert a version string of the form 1.23.57 to a comparable integer of
* the form 12357.
*
* Or throw an exception if the string can not be parsed
*/
Tff7b72private Tff7b72fun Td2a8ffverStringToIntTb4b4b4(Te6edf3sTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Tffa657Int Tb4b4b4{
T8b949e// Allow 1 to two digits per match
Tff7b72val Te6edf3match Tff7b72=
Te6edf3RegexTb4b4b4(Ta5d6ff"Ta5d6ff(Ta5d6ff\\Ta5d6ffd{1,2}).(Ta5d6ff\\Ta5d6ffd{1,2}).(Ta5d6ff\\Ta5d6ffd{1,2})Ta5d6ff"Tb4b4b4)Tb4b4b4.Te6edf3findTb4b4b4(Te6edf3sTb4b4b4)
Tff7b72?: Tff7b72throw Te6edf3ExceptionTb4b4b4(Ta5d6ff"Ta5d6ffCan't parse version Tffd700$Te6edf3sTa5d6ff"Tb4b4b4)
Tff7b72val Tb4b4b4(Te6edf3majorTb4b4b4, Te6edf3minorTb4b4b4, Te6edf3buildTb4b4b4) Tff7b72= Te6edf3matchTb4b4b4.Te6edf3destructured
Tff7b72return Te6edf3majorTb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4) Tff7b72* T79c0ff1T79c0ff0T79c0ff0T79c0ff0T79c0ff0 Tff7b72+ Te6edf3minorTb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4) Tff7b72* T79c0ff1T79c0ff0T79c0ff0 Tff7b72+ Te6edf3buildTb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4)
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffcompareToTb4b4b4(Te6edf3otherTb4b4b4: Te6edf3DeviceVersionTb4b4b4)Tb4b4b4: Tffa657Int Tff7b72= Te6edf3asInt Tff7b72- Te6edf3otherTb4b4b4.Te6edf3asInt
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.08s